<link href="<?php echo Yii::app()->theme->baseUrl; ?>/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<div class="col-md-14">
    <div class="box box-primary">
        <div class="box-header">
            <h3 class="box-title">Xem tất cả hóa đơn của đối tác <span class="mame-ten"><?php echo $model->ten; ?></span>, mã số: <span class="ma-doitac"><?php echo $model->ma_so; ?></span></h3>
        </div><!-- /.box-header -->
        <div class="box-body">
            <dl class="dl-horizontal">
                <dt>Tổng doanh thu</dt>
                <dd><?php echo getMoney($model->tong_doanh_thu); ?></dd>
                <dt>Tổng chi phí</dt>
                <dd class="tongchiphi"><?php echo getMoney($model->tong_chi_phi); ?></dd>
                <dt>Chưa thanh toán</dt>
                <dd class="chua-thanhtoan"><?php echo getMoney($model->chua_thanh_toan); ?></dd>
                <dt>Đã thanh toán</dt>
                <dd class="da-thanhtoan"><?php echo ($model->da_thanh_toan); ?></dd>
            </dl>
            <div class="pull-left">
                <input type="text" id="date1">
                đến
                <input type="text" id="date2">
                <button id="loc">Lọc</button>
            </div>
            <div class="pull-right" style="margin-bottom:10px;">
                <?php echo CHtml::image("images/trangthai-0.png", "DORE",array("class"=>"image_view")); ?><label>Chưa thanh toán</label>
                <?php echo CHtml::image("images/trangthai-1.png", "DORE",array("class"=>"image_view")); ?><label>Thanh toán một phần</label>
                <?php echo CHtml::image("images/trangthai-2.png", "DORE",array("class"=>"image_view")); ?><label>Đã thanh toán</label>
            </div>
            <?php $this->widget('ext.GLGridView', array(
                'id'=>'doitac-grid1',
                'cssFile' => Yii::app()->theme->baseUrl . '/css/gridView.css',
                'dataProvider'=>$data->search("id_doitac = {$model->id}"),
                'filter'=>$data,
                'columns'=>array(
                    array(
                        'name'=>'id',
                        'type'=> 'raw',
                        'value'=> 'CHtml::hiddenField("id", $data->id,array("class"=>"idhoadon")).$data->id', 
                    ),
                    array(
                        'name'=>'id_khachhang',
                        'htmlOptions'=>array('class'=>'name-ten'),
                        'value'=> '$data->khachhang == null ? "Không có" : $data->khachhang->ten',
                    ),
                    array(
                        'name'=>'id_doitac',
                        'htmlOptions'=>array('class'=>'name-ten'),
                        'value'=> '$data->doitac == null ? "Không có" : $data->doitac->ten',
                    ),
                    array(
                        'name'=>'ma_so_doi_tac',
                        'value'=>'$data->doitac == null ? "Không có" : $data->doitac->ma_so',
                        'htmlOptions'=>array('class'=>'ma-doitac'),
                    ),
                    'ngay_su_dung',
                    array(
                        'name'=>'ngay_thanh_toan_dt',
                        'value'=>'$data->ngay_thanh_toan_dt == "0000-00-00" ? "N/A" : $data->ngay_thanh_toan_dt'
                    ),
                    'so_phieu_thanh_toan',
                    array(
                        'name'=>'chung_tu_thanh_toan',
                        'value'=>'$data->chung_tu_thanh_toan == null  ? "N/A" : $data->chung_tu_thanh_toan',
                    ),
                    array(
                        'name'=>'so_tien',
                        'value'=>'getMoney($data->so_tien)'
                    ),
                    array(
                        'name'=>'chua_thanh_toan_dt',
                        'value'=>'getMoney($data->chua_thanh_toan_dt)'
                    ),
                    array(
                        'name'=>'chiet_khau',
                        'value'=>'getMoney($data->chiet_khau)'
                    ),
                    array(
                        'name'=>'trangthai_thanhtoan_dt',
                        'type'=>'raw',
                    'value'=> 'CHtml::image("images/trangthai-{$data->trangthai_thanhtoan_dt}.png", "DORE",array("class"=>"image"));', 
                        'filter'=>CHtml::dropDownList('DoitacKhachhang[trangthai_thanhtoan]','trangthai_thanhtoan',  
                                    array(
                                        ''=>'Tất cả',
                                        '0'=>'Chưa thanh toán',
                                        '1'=>'Thanh toán 1 phần',
                                        '2'=>'Đã thanh toán',
                                    )
                                ),
                    ),
                ),
            )); ?>
            <div class="box-footer" style="margin-top: 35px;">
                <a href="<?php echo Yii::app()->createUrl('/DoiTac/doitacKhachhang/nhapmothoadon',array('id'=>$model->id)); ?>" class="btn btn-danger">Nhập hóa đơn</a>
                <div class="dropdown pull-right">
                    <a href="<?php echo Yii::app()->createUrl('/DoiTac/doitacKhachhang/doitacexcel',array('id'=>$model->id)); ?>" class="btn btn-default">Triết xuất excel</a>
                </div>
            </div>
        </div>
    </div><!-- /.box -->
</div>
<script type="text/javascript">
    $( "#date1" ).datepicker();
    $( "#date2" ).datepicker();
    $('body').on('click', '#loc', function(event) {
        if ($('#date1').val() != '' && $('#date2').val() != '') {
            var date1 = $('#date1').val();
            var date2 = $('#date2').val();
            $.fn.yiiGridView.update('doitac-grid1',{data: {date1:date1,date2:date2}});
        };
    }); 
</script>
<style type="text/css">
    #doitac-grid1{
        margin-top: 70px;
    }
    .input_text{
        width: 30%;
        margin-bottom: 10px;
    }
    .tokenfield{
        margin-bottom: 10px;   
        width: 30%;
    }
    .error{
        border-color: #f56954 !important;
        box-shadow: none;
    }
    .ui-autocomplete{
        width: 19% !important;
        min-width: 12% !important;
    }
</style>
<style type="text/css">
    .box .box-body .table {
        margin-bottom: 27px;
        }
</style>